package cn.tedu.study.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author:yuziji
 * @create: 2023-06-01 10:09
 * @description:封装统一返回结果
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ResultVO {
    private Integer code;
    private String message;
    private Object data;

    public ResultVO(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultVO(StatusCode statusCode, Object data) {
        this(statusCode);
        this.data = data;
    }

    public ResultVO(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public static ResultVO ok(Object data) {
        ResultVO resultVo = new ResultVO(StatusCode.SUCCESS, data);
        return resultVo;
    }

    public static ResultVO ok() {
        return ok(null);
    }

}
